import os

from PIL import Image,ImageSequence

gif = Image.open(r'test.gif')

if os.path.exists("output1") == False:

    os.mkdir("output1")

for i,frame in enumerate(ImageSequence.Iterator(gif),1):

    frame.save(r'output1/%d.png'%i)
